package com.shujia.wyh.day11;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/*
    HashMap嵌套ArrayList

 */
public class MapTest3 {
    public static void main(String[] args) {
        HashMap<String, ArrayList<Student>> shujia = new HashMap<>();

        //创建4个班级
        ArrayList<Student> clazz21 = new ArrayList<>();
        clazz21.add(new Student("张三", 18));
        clazz21.add(new Student("李四", 17));
        shujia.put("21期", clazz21);

        ArrayList<Student> clazz22 = new ArrayList<>();
        clazz22.add(new Student("王五", 18));
        clazz22.add(new Student("王二麻", 20));
        shujia.put("22期", clazz22);


        ArrayList<Student> clazz23 = new ArrayList<>();
        clazz23.add(new Student("吴涛", 16));
        clazz23.add(new Student("陈涛", 17));
        clazz23.add(new Student("王硕", 15));
        shujia.put("23期", clazz23);

        Set<Map.Entry<String, ArrayList<Student>>> entries = shujia.entrySet();
        for (Map.Entry<String, ArrayList<Student>> entry : entries) {
            String name = entry.getKey();
            ArrayList<Student> clazz = entry.getValue();
            System.out.println("当前是" + name);
            for (Student student : clazz) {
                System.out.println(student);
            }
        }


    }
}
